//
//  DDInvoice.swift
//  DingDongZP
//
//  Created by 三秒文化 on 2016/10/14.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

import UIKit

class DDInvoice: LDBaseCustomizeVC {
    
    var listTitle:[Dictionary<String, String>]?
    var tableView:LDBaseTableView?
    
    override func viewDidLoad() {
        
        super.viewDidLoad()
        title = "发票"
        
        listTitle = [["title":"我要开票"],["title":"发票信息设置"],["title":"开票历史记录"]];
        let marginView = UIView.init(frame: CGRectMake(0, 0, LDFrame.ScreenWidth, LDFrame.TableCellMargin))
        marginView.backgroundColor = LDGolbalColor.BgGoundGray
        
        tableView = LDBaseTableView.init(frame: view.frame, style: UITableViewStyle.Plain)
        tableView!.tableHeaderView = marginView
        
        tableView?.delegate = self
        tableView?.dataSource = self
        
        view.addSubview(tableView!)
        rdv_tabBarController.setTabBarHidden(true, animated: false)
    }
    
}

extension DDInvoice:UITableViewDelegate,UITableViewDataSource {
    
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return listTitle!.count
    }
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        var cells:baseMySettingCells?
        cells = tableView.dequeueReusableCellWithIdentifier("cellinvocie") as? baseMySettingCells
        
        if cells == nil {
            cells = baseMySettingCells.init(style: UITableViewCellStyle.Default, reuseIdentifier: "cellinvocie")
        }
        
        cells?.model = baseMySettingCellsModel.yy_modelWithDictionary(listTitle![indexPath.row])
        return cells!
    }
    
    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath)
        -> CGFloat {
            
            return 48
    }
    
    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        
        
        switch indexPath.row {
            
        case 0:
            
            let vc = DDOpenInvoice()
            vc.title = "我要开票"
            navigationController?.pushViewController(vc, animated: true)
    
        case 1:
            
            let vc = DDInvoiceSettingInfoVC()
            vc.title = "发票信息设置"
            navigationController?.pushViewController(vc, animated: true)
            
        case 2:
            
            let vc = DDOpenInvoiceHistory()
            vc.title = "开票历史记录"
            navigationController?.pushViewController(vc, animated: true)
            
        default:
            break
            
        }
    }
}
